package com.example.myapplication

import com.example.myapplication.clean_craftsmanship.MyQueue
import org.junit.Test
import org.junit.Assert.*

class QueueTest {
    val myQueue = MyQueue()

    @Test
    fun createQueue() {

    }

    @Test
    fun pushQueue() {
        myQueue.push(0)
        print(myQueue.isEmpty())
    }

    @Test
    fun onePushAndGetTop() {
        myQueue.push(0)
        assertEquals(0, myQueue.getTop())
        myQueue.push(1)
        assertEquals(1, myQueue.getTop())
    }

    @Test
    fun onePop_throw() {
        myQueue.pop()
    }

    @Test
    fun afterOnePushAndOnePop_isEmpty() {
        myQueue.push(1)
        myQueue.pop()
        println(myQueue.isEmpty())
    }

    @Test
    fun getSize() {
        myQueue.push(1)
        myQueue.push(1)
        myQueue.push(1)
        println(myQueue.getSize())
    }

    @Test
    fun afterTwoPushAneOnePop_isNotEmpty() {
        myQueue.push(0)
        myQueue.push(0)
        myQueue.pop()
        println(myQueue.isEmpty())
    }

    @Test
    fun afterOnePushAneTwoPop_throw() {
        myQueue.push(0)
        myQueue.pop()
        myQueue.pop()
        println(myQueue.isEmpty())
    }

    @Test
    fun afterTwoPushAneOnePop_getSize() {
        myQueue.push(0)
        myQueue.push(0)
        myQueue.pop()
        println(myQueue.getSize())
    }

    @Test
    fun getLast_throw() {
        println(myQueue.getLast())
    }

    @Test
    fun onePushAndGetLast() {
        myQueue.push(1)
        println(myQueue.getLast())
    }

    @Test
    fun twoPushAndGetLast() {
        myQueue.push(1)
        myQueue.push(2)
        println(myQueue.getLast())
    }

    @Test
    fun 质因数() {
        val list = mutableListOf<Int>()
        var d = 2
        var n = 24
        while (n > 1) {
            while (n % d == 0) {
                list.add(d)
                n /= d
            }
            d++
        }
        println(list)
    }

}